/*
 * =====================================================================================
 *
 *       Filename:  main.c
 *
 *    Description:  example of signal
 *
 *        Version:  1.0
 *        Created:  04/25/12 17:27:14
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *        Company:  
 *
 * =====================================================================================
 */
#include    <signal.h>
#include    <unistd.h>
#include    <stdlib.h>
#include    <stdio.h>
#include    <errno.h>

//one handler for signal
static void sig_usr(int);

int main(void)
{
    if (signal(SIGINT, sig_usr) == SIG_ERR)
    {
        printf("signal error:%s\n", strerror(errno));
        return -1;
    }
    sleep(15);
    while(1);

    return 0;
}

static void sig_usr(int signo)
{
    if (SIGINT == signo)
    {
        printf("recved Ctrl+C\n");
        exit(0);
    }
}
